Skip to main content

Quickstart KMP (iOS)

Step 1 - Opening the KMP project in Xcode

  1. Access the iosApp folder created by KMP.
  2. Open the iosApp.xcodeproj file in Xcode.

Finder window on macOS showing the contents of the 'iosApp' folder. The 'iosApp' folder name at the top of the window is highlighted in red, and the iosApp.xcodeproj file is highlighted in red with an arrow pointing to it.

Step 2 - Editing the Info.plist file using the Xcode visual editor

All permissions for your iOS application are listed in the Custom iOS Target Properties section of Info.plist.

  1. In the file browser (left panel), select your project at the top of the tree.
  2. Select the application's target in TARGETS.
  3. Access the Info tab.

Xcode window showing the Info tab of the target. Three areas are highlighted in red: the project name at the top of the left navigator, the application target in the TARGETS section, and the Info tab at the top of the editor. On the right, the Custom iOS Target Properties section lists the permission keys and their respective values.

Step 3 - Adding permissions

Note: Description messages are displayed when the application requests permission from the user to use a service. Be sure to add a message that is meaningful to your users.

Enable Location Services

To obtain beacon range results, Group Link technology requires Always location authorization. When implementing location services in your app, Apple requires the following keys to be added to your Info.plist file:

  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysAndWhenInUseUsageDescription

Example Description: Location helps ensure more accurate readings and correct alerts about water consumption. This allows the app to deliver consumption data from your home.

Location permissions configuration in the Info.plist editor.

Enable Bluetooth Services

Since iOS 13, apps are required to add the Bluetooth permission key to the Info.plist file.

  • NSBluetoothAlwaysUsageDescription

Example Description: To ensure the quality of consumption readings, the app needs to access Bluetooth, which helps collect data more accurately.

Bluetooth permission configuration in the Info.plist editor.

Apps supported for iOS 12 and below

If your application can run on older versions of iOS (iOS 12 and below), you will need to place the Bluetooth Peripheral key within your Info.plist file:

  • NSBluetoothPeripheralUsageDescription

Example Description: To ensure the quality of consumption readings, the app needs to access Bluetooth, which helps collect data more accurately.

Bluetooth Peripheral permission configuration in the Info.plist editor.

Enable background task functionality

To enable background tasks in your application, you need to insert the following key into your Info.plist file:

  • BGTaskSchedulerPermittedIdentifiers

Open the created key, Permitted background task scheduler identifiers, and enter our identifier:

  • com.grouplinknetwork.bgtask

Background task scheduler permitted identifiers configuration in the Info.plist editor.

Step 4 - Signature Permissions and Capabilities

  1. Select the application's target in TARGETS.
  2. Access the Signing & Capabilities tab.
  3. Click the + Capability button to add the following capabilities:

Signing & Capabilities tab of the application target in Xcode. Three areas are highlighted in red: the application target in the 'TARGETS' section, the 'Signing & Capabilities' tab at the top, and the '+ Capability' button.

Enable Access to WiFi Information

Your application must be able to access WiFi network information for Group Link technology to function correctly. To achieve this, you must add the following capability:

  • Access WiFi Information

Access WiFi Information capability added in the Signing & Capabilities tab.

Enable Necessary Background Modes

Your application must be able to run in background modes for Group Link technology to function correctly. To achieve this, you must add the following capability:

  • Background Modes

Background Modes capability added in the Signing & Capabilities tab.

Select the following authorizations from the list:

  1. Location updates
  2. Uses Bluetooth LE accessories
  3. Acts as a Bluetooth LE accessory
  4. Background fetch
  5. Background processing

The five required Background Modes selected in the Signing & Capabilities tab.

Adding a new package to your project

  1. In Xcode, locate the panel on the left and click on your PROJECT.
  2. At the top of the open window, click the Package Dependencies tab.
  3. The list of packages used in the project will appear.
  4. Click the + button located in the lower left of this list to add a new package.

Xcode screen with three areas highlighted in red: the PROJECT section of the left sidebar, the Package Dependencies tab at the top of the editor, and the '+' button at the bottom of the packages list. The Packages list is empty (0 items), showing the message "Add packages here".

Searching for the package via the GitHub URL

  1. In the search field, in the upper right corner of the window, paste the repository URL: https://github.com/Group-Link-Mobile/grouplink-package
  2. In a few moments, the result grouplink-package will appear in the list.
  3. Click on the grouplink-package to select it.
  4. Change the Dependency Rule to Up to Next Minor Version and add the version 6.2.0.
  5. Click Add Package to add the grouplink-package to the project.

⚠️ Attention: In the Dependency Rule, do not use the options Up to Next Major Version, Branch, Exact Version, Range of Versions or Commit. The correct configuration is Up to Next Minor Version → 6.2.0. This configuration ensures that you will always use a compatible SDK version published by Group Link.

Swift Package Manager (SPM) add window in Xcode with the search returning the grouplink-package repository. The URL appears highlighted in red in the search field in the upper right corner, and the grouplink-package is highlighted in red in the results list. The Dependency Rule fields set to Up to Next Minor Version with the value '6.2.0' are highlighted in yellow.

Choosing the products for the package

Xcode will resolve the package and open the Choose Package Products for grouplink-package.git window.

  1. Check if the GroupLink package is in the list.
  2. In the Add to Target column, confirm that it is associated with your application.
  3. Click Add Package to confirm adding the package.

Selection modal for the grouplink-package in Xcode, listing the GroupLink product of type Library to be added to the target. The Add Package button, in the lower right corner of the dialog, is highlighted in red.

Verifying the installation

After completion, you will return to the Package Dependencies tab. There, confirm that everything is correct:

  • The list should now display the GroupLink-iOS package.
  • The GroupLink-iOS package appears with:
    • Location: https://github.com/Group-Link-Mobile/grouplink-package
    • Dependency Rule: Up to Next Minor Version
    • Value: 6.2.0

Package Dependencies tab of the project in Xcode, showing 1 item in the Packages list. The GroupLink package appears with the location pointing to the GitHub repository and the Dependency Rule set to Up to Next Minor Version 6.2.0.

To initialize the SDK, you need to pass your authentication Token (provided by Group Link).

  • Import the SDK library.
  • In the start method, specify your authentication Token (provided by Group Link) in the withToken parameter.
  • Call the startBluetooth and startLocation methods to request Bluetooth and Location permissions.
import SwiftUI

import GroupLink // <---- Importing the Group Link SDK

@main
struct iOSApp: App {
init() {
// 1 - Initializing the SDK Group Link
GroupLinkSDK.start(withToken: "YOUR_GROUP_LINK_TOKEN")

// 2 - Requesting Bluetooth permission
GroupLinkSDK.startBluetooth()

// 2 - Requesting Location Permission
GroupLinkSDK.startLocation()
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Now that the Group Link SDK for iOS is implemented and the native features are configured, your KMP app is ready to interact with our ecosystem!